package com.shoulei.designpattern.ChainOfResponsibilityPattern;

/**
 * @ClassName:ChainPatternDemo
 * @Descrition:
 * @Author:shoulei
 * @Date:2019/4/14 16:50
 * @Verson:
 */
public class ChainPatternDemo {
    private static AbstractLogger getChainOfLoggers(){
        AbstractLogger errorLogger = new ErrorLogger(AbstractLogger.ERROR);
        AbstractLogger fileLogger = new FileLogger(AbstractLogger.DEBUG);
        AbstractLogger consoleLogger = new ConsoleLogger(AbstractLogger.INFO);
        errorLogger.setNextLogger(fileLogger);
        fileLogger.setNextLogger(consoleLogger);
        return errorLogger;
    }

    public static void main(String[] args) {
        AbstractLogger loggerChain = getChainOfLoggers();
        loggerChain.logMessage(AbstractLogger.INFO,"this ia a info");
        loggerChain.logMessage(AbstractLogger.DEBUG,"this is a debug");
        loggerChain.logMessage(AbstractLogger.ERROR,"this is a error");
    }
}
